home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Installation Tools & Overlays 2001 May
/
SGI IRIX Installation Tools & Overlays 2001 May - Disc 3.iso
/
relnotes
/
c++_eoe
/
ch4.z
/
ch4
Wrap
Text File
|
2001-04-16
|
16KB
|
593 lines
- 1 -
7.3.1.1m C++ Compiler Execution Environment Release Notes
- 2 -
4. _N_e_w__F_e_a_t_u_r_e_s
This chapter lists the new C++ features for the MIPSpro 7.3
release.
4.1 _T_e_m_p_l_a_t_e_-_R_e_l_a_t_e_d__f_e_a_t_u_r_e_s
New C++ template-related features are described in the
following sections.
4.1.1 _O_v_e_r_l_o_a_d_e_d__F_u_n_c_t_i_o_n__T_e_m_p_l_a_t_e_s
The 2.38 front end now permits you to overload a function
template, as in the following example.
template <class T> void f(T t); (1)
template <class X> void f(X p*); (2)
When you call an overloaded function template, the compiler
selects the most specific version that matches the argument.
If the function f is overloaded as in the previous example,
the compiler selects version (1) when you write f(10) and it
selects version (2) when you write f((double*) 0). (Previous
versions of the compiler would issue an error in this case.)
The C++ standard refers to this feature as "partial ordering
of function templates." It is sometimes also called
"partial specialization of functions."
4.1.2 _E_x_p_l_i_c_i_t__S_p_e_c_i_f_i_c_a_t_i_o_n__o_f__F_u_n_c_t_i_o_n__T_e_m_p_l_a_t_e__A_r_g_u_m_e_n_t_s
The usual way of calling a function template is the same as
calling an ordinary function. If you write f(10), for
example, the compiler deduces the types of the template
parameters. It is now also possible to specify the template
arguments explicitly, as in f<int>(10).
This feature makes it possible to write function templates
whose template arguments cannot be deduced. For example:
template <class T>
inline T* null_pointer() { return (T*) 0; }
It is impossible for the compiler to deduce the type of the
template argument of null_pointer from the function's
arguments because the function takes no arguments. You must
explicitly provide the template arguments when you call this
- 3 -
function, as in the following example:
null_pointer<X>().
Previous versions of the compiler did not permit function
templates with template arguments that could not be deduced.
4.1.3 _U_n_n_a_m_e_d__T_e_m_p_l_a_t_e__P_a_r_a_m_e_t_e_r_s
Unnamed template parameters are now legal, as in the
following example:
template <class,int> struct A {};
A<char,1> a1;
4.1.4 _N_e_w__S_y_n_t_a_x__f_o_r__R_e_f_e_r_r_i_n_g__t_o__T_e_m_p_l_a_t_e__M_e_m_b_e_r_s
The C++ standard allows (and in some cases requires) a new
syntax for referring to a member template of a class. If a
class A has a member template B<T>, you can write
A::template B<T>, or a.template B<T>, or pa->template B<T>.
Example:
struct X {
template <class T> struct Y;
template <class T> void f();
template <class T> void g(T);
};
X x;
X::template Y<int> y;
x.template f<int>();
x.g(10); // No "template" keyword here, because we are
// not providing g's template argument list.
In this example, the new syntax is not required. It is
required in only one specific case: when you are referring
to a member template of a class that itself depends on a
template parameter.
Example:
template <class T>
void f(T t) {
T::template Y<int> y;
...
}
- 4 -
The new syntax is required in this case because the compiler
must be able to interpret "<" as the beginning of a template
argument list or as a less-than operator.
(Previous releases of the compiler neither required nor
allowed the new syntax. This release allows it but does not
require it. Future releases might require it.)
4.2 _N_e_w__C_o_m_p_i_l_e_r__C_o_m_m_a_n_d__L_i_n_e__O_p_t_i_o_n_s
The following sections describe new compiler options for
C++.
4.2.1 _I_n_t_e_r_p_r_o_c_e_d_u_r_a_l__P_a_r_a_l_l_e_l_i_z_a_t_i_o_n
The -ipa option invokes the Interprocedural Analyzer option
group. This is a new alias for -IPA:=ON. Compiling with the
-ipa and -pfa options together instructs the compiler to
perform interprocedural parallelization. The compiler
applies a sophisticated analysis to determine when it can
parallelize loops with calls.
4.2.2 _L_i_s_t_i_n_g__C_o_n_t_r_o_l
The -clist option invokes the listing control group. This
is equivalent to -CLIST:=ON.
The emit_omp=_f_l_a_g suboption to the -CLIST option directs the
compiler to use OpenMP directives (_f_l_a_g=ON) or MIPS(TM)
multiprocessing directives (_f_l_a_g=OFF).
4.2.3 _M_e_m_o_r_y__L_o_c_a_t_i_o_n
The speculative_ptr_deref={ON/OFF} suboption to the -OPT
compiler option allows speculative loads of memory locations
that differ by a small offset from some referenced memory
location. For more information, see the opt(5) man page.
4.2.4 _P_a_r_a_l_l_e_l_i_z_a_t_i_o_n__A_n_a_l_y_s_i_s
The -LNO:pure={_f_l_a_g} option tells the compiler how to use
the "no side effects" and "pure" pragmas when gathering
information about calls for parallelization analysis.
- 5 -
4.2.5 _T_a_r_g_e_t__O_p_t_i_o_n__G_r_o_u_p__C_o_n_t_r_o_l_s
The target option group has the following new controls:
dismiss_mem_faults=_f_l_a_g Forces the kernel to dismiss memory
faults that occur during execution.
exc_max=_v_a_l_u_e Specifies the maximum set of IEEE-
754 floating point exceptions for
which traps can be enabled at run
time.
exc_min=_v_a_l_u_e Specifies the minimum set of IEEE-
754 floating point exceptions for
which traps must be enabled at run
time.
isa=_v_a_l_u_e Identifies the target instruction
set architecture for compilation.
sync=_f_l_a_g Enables or disables the use of SYNC
instructions.
4.2.6 _-_T_E_N_V__S_u_b_o_p_t_i_o_n
The large_got=ON/OFF suboption to the -TENV compiler option
replaces the -avoid_gp_overflow and the -xgot options.
4.3 _O_t_h_e_r__N_e_w__F_e_a_t_u_r_e_s
The following sections describe other new C++ features.
4.3.1 _C_-_C_a_l_l_a_b_l_e__R_o_u_t_i_n_e_s
C-callable versions of POPCNT, POPPAR, LEADZ, and MASK are
now available.
4.3.2 _C_o_v_a_r_i_a_n_t__R_e_t_u_r_n__T_y_p_e_s
Usually, when a derived class overrides a base class's
virtual member function, the function in the derived class
must have exactly the same signature as in the base class.
There is, however, one small exception.
If a virtual function in a base class returns a pointer (or
reference) to a class X, the overriding virtual function can
- 6 -
return a pointer to X or to some other class that inherits
from X.
Example:
struct X {
virtual ~X() {}
virtual X* clone() const { return new X(*this); }
};
struct Y : public X {
virtual Y* clone() const { return new Y(*this); }
};
Previous compiler releases did not permit covariant return
types. They required a virtual member function in a derived
class to have exactly the same return type as in the base
class.
4.3.3 _L_o_o_k_u_p _R_u_l_e_s _f_o_r _M_e_m_b_e_r _R_e_f_e_r_e_n_c_e_s _o_f _t_h_e _F_o_r_m _x._A::_B
_a_n_d _p->_A::_B
In a class member access expression like x.A::i or p->A::i,
the class reference (in this case A) is looked up both in
the context of the expression and in the context of the left
operand of the "." or "->" operator (in this case, the class
of which x is a member). Formerly, the class reference was
looked up only in the first context, as in the following
example:
struct A {
typedef A B;
int i;
};
int main() {
A a;
a.B:: i = 1; // not previously allowed
}
4.3.4 _N_e_w__#_p_r_a_g_m_a
The unknown_control_flow (_f_u_n_c_1 [, _f_u_n_c_2 ...]) #pragma
indicates that the procedures listed as _f_u_n_c_1 and _f_u_n_c_2,
etc. have a nonstandard control flow behavior.
- 7 -
4.3.5 _O_p_e_n_M_P__D_i_r_e_c_t_i_v_e_s__f_o_r__S_h_a_r_e_d__M_e_m_o_r_y__M_u_l_t_i_p_r_o_c_e_s_s_i_n_g
OpenMP directives are based on the OpenMP C/C++ application
programming interface (API) standard. Programs that use
these directives are portable and can be compiled by other
compilers that support the OpenMP standard.
To enable recognition of the OpenMP directives, specify -mp
on the cc or CC command line. Details of these directives
are documented in the _M_I_P_S_p_r_o _C _a_n_d _C++ _P_r_a_g_m_a_s manual.
4.3.6 _O_v_e_r_l_o_a_d_i_n_g__o_n__E_n_u_m_e_r_a_t_i_o_n_s
You cannot overload an operator if all of its arguments are
built-in types, but you can overload it if at least one
argument is a class or enumeration type.
Example:
enum E {a, b, c, error};
E operator++ (E e) {
switch(e) {
case a:
return b;
case b:
return c;
case c:
return a;
default:
return error;
}
}
Previous compiler releases did not allow overloaded
operators all of whose arguments were enumeration types.
4.3.7 _S_t_a_n_d_a_r_d__C_+_+__L_i_b_r_a_r_y
A standard C++ library is now available. This library
includes a standard-conforming I/O library, which has new
header names. For example, the old iostream.h header is now
iostream. The functionality for this feature is provided in
libCio.so, which is provided for n32- and 64-bit ABIs. Using
the new library requires including the -LANG:std option on
the command line. The -LANG:std option also triggers the
following ISO/ANSI standard-conforming behavior:
- 8 -
+o A user-defined assignment operator for class X is a
nonstatic nontemplate operator= with a single parameter
of one of the following types:
X
X&
const X&
volatile X&
const volatile X&
A template operator= or an operator= with a different
type (even if the type is derived from X) is not
considered to be an assignment operator, and does not
prevent the compiler from generating an implicit
operator=.
+o The typename keyword cannot be omitted where the
standard mandates it.
+o The scope of a variable declared in the initialization
of a for-loop is the for-loop and not the surrounding
scope.
+o Guiding declarations are not allowed.
+o Old-style template specializations are not allowed.
The new template syntax is now required for complete
specializations.
+o When you use -LANG:std, there is no longer an implicit
conversion from function pointer types to void*.
However, it is still possible to do the conversion with
a cast.
+o When you use -LANG:std, operator new throws a bad_alloc
exception to signal out of memory, rather than
returning a null pointer.
+o The overload resolution rules are now stricter in the
sense that some old tie-breaker rules have been
abolished. The effect of this is that some function
calls that were resolved by these discarded rules are
now ambiguous. For example, consider the following
code:
struct X {
X(int);
};
void f(int, const int *);
void f(X, int *);
- 9 -
int main()
{
int *p;
f(1, p);
}
If -LANG:std is specified, the call to f(1, p) becomes
ambiguous. Because f(int, const int*) is preferred for
the first argument but f(X, int *) is preferred for the
second, no attempt is made to reconsider and break the
tie.
+o The _STANDARD_C_PLUS_PLUS macro is defined.
4.3.8 _S_u_p_e_r_c_o_m_p_u_t_i_n_g__A_P_I__S_u_p_p_o_r_t
The MIPSpro 7.3 release supports the Supercomputing
Application Programming Interface (API), a set of language
features and library functions that are implemented across
the Silicon Graphics and Cray(TM) product line to meet the
application portability needs of high-performance, technical
computing customers. For more information, see the online
Supercomputing API document at the following URL:
http://www.sgi.com/software/scapi.html